<?php
//echo '!!!!!!!!!!!elementtest';
require_once( 'PHPUnit.php' );
require_once( 'cube/controller.php' );
require_once( 'odal/element.php' );
require_once( 'odal/omsdata.php' );
require_once( 'odal/xmlvisualizer.php' );

class element_Test extends PHPUnit_TestCase{
	var $m_structure;
	var $m_omsdata;
	
	function setup(){
//		echo '!!!!!!!!!!!SETUP';
		$this->m_omsdata =& new odal_OMSData( "cube.core.data", "omscube11test", 0 );
	}//setup

//	function testDisconnect(){
////		print_r( $this->m_structure->m_assocs );
//		$oStructure =& $this->m_omsdata->getOmsstructureByWhere( 'elm_id in ( 65, 4280 )' );
////		$this->_displayStructure( $oStructure  );
//		$oEventElement =& $oStructure->getElementById( 65 );
//		$oEventElement->disconnect( 'ass_event2account', $oStructure->getElementById( 4280 ) );
////		$this->_displayStructure();
////		$this->m_omsdata->saveOmsStructure( $oStructure, false );
////		$this->_displayStructure();
//	}//testDisconnect
//
//	function testGetKey(){
//		$oStructure =& $this->m_omsdata->getOmsstructureByWhere( 'elm_id in ( 65, 4280 )' );
//		$oEventElement =& $oStructure->getElementById( 65 );
//		$key = $oEventElement->getKey( 'ass_event2account', $oStructure->getElementById( 4280 ) );
//		$this->assertEquals( 3910, $key );
//	}//testGetKey
//	
//	function testDeleteElement(){
//		$oStructure =& $this->m_omsdata->getOmsstructureByWhere( 'elm_id in ( 65 )' );
//		$oElement =& $oStructure->getElementById( 65 );
//		$oElement->delete();
//		$this->_displayStructure( $oStructure );
//	}//testDeleteElement

	function testGetCmpPath() {
		$oStructure =& $this->m_omsdata->getOmsstructureByWhere( "elm_bookmark = 'Test'" );
//		$this->_displayStructure( $oStructure );
		$oElement =& $oStructure->getElementByBookmark( 'Test' );
		$path = $oElement->getCmpPath();
		echo '[elementtest->testGetCmpPath] $path: *' . $path . "*<br>\n";
	}//testGetCmpPath

	function testGetCmpLevel() {
		$oStructure =& $this->m_omsdata->getOmsstructureByWhere( "elm_bookmark = 'Test'" );
//		$this->_displayStructure( $oStructure );
		$oElement =& $oStructure->getElementByBookmark( 'Test' );
		$level = $oElement->getCmpLevel();
		echo '[elementtest->testGetCmpPath] $level: *' . $level . "*<br>\n";
	}//testGetCmpLevel
	
	function _displayStructure( &$p_oStructure ){	
		echo '************************************************<br>';
		$xMLVisualizer =& new odal_XMLVisualizer( $p_oStructure  );
		echo $xMLVisualizer->getOmsStructureAsXML();
		echo '************************************************<br>';
	}//_displayStructure
	

}//element_Test
?>
